package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.ArticleComment;
import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.mapper.ArticleCommentMapper;
import cn.wolfcode.trip.base.mapper.UserMapper;
import cn.wolfcode.trip.base.query.TravelCommendQueryObject;
import cn.wolfcode.trip.base.query.UserQueryObject;
import cn.wolfcode.trip.base.service.IArticleCommentService;
import cn.wolfcode.trip.base.service.IUserService;
import cn.wolfcode.trip.base.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class ArticleCommentServiceImpl implements IArticleCommentService {
    @Autowired
    private ArticleCommentMapper commentMapper;

    public PageInfo<ArticleComment> queryForComments(TravelCommendQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        List<ArticleComment> articleComment = commentMapper.queryForComments(qo);
        return new PageInfo(articleComment);
    }

    public void saveArticleComment(ArticleComment articleComment) {
        articleComment.setCreateTime(new Date());
        articleComment.setUser(UserContext.getUser());
        commentMapper.saveArticleComment(articleComment);
    }

    public PageInfo<ArticleComment> selectForCommendById(TravelCommendQueryObject queryObject) {
        PageHelper.startPage(queryObject.getCurrentPage(), queryObject.getPageSize(), queryObject.getOrderBy());
        List<ArticleComment> articleComment = commentMapper.selectForCommendById(queryObject);
        return new PageInfo(articleComment);
    }
}
